package com.crawl;

import com.crawl.proxy.ProxyHttpClient;
import com.crawl.view.HttpRequestHandler;
import com.crawl.zhihu.ZhiHuHttpClient;
import com.sun.net.httpserver.HttpServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.concurrent.Executors;

/**
 * 爬虫入口
 */
public class Main {
    private static Logger logger = LoggerFactory.getLogger(Main.class);
    public static void main(String args []) throws IOException {
        InetSocketAddress addr = new InetSocketAddress(8080);
        HttpServer server = HttpServer.create(addr, 0);
        server.createContext("/zhihu-data-analysis", new HttpRequestHandler());
        server.setExecutor(Executors.newCachedThreadPool());
        server.start();

        ProxyHttpClient.getInstance().startCrawl();
        ZhiHuHttpClient.getInstance().startCrawl();


    }
}
